package com.suixinsanren.design.responsibilitychain.demo01;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class StNoCheck extends AbsCheckStudent {

    private final Integer ST_NO_MAX_LEN = 20;
    private final String NON_STR = "";

    @Override
    public List<Student> checkStudent(List<Student> studentList) {
        List<Student> stNoIsNotOk = studentList.stream().filter(stu -> {
            String stNo = stu.getStNo();
            return Objects.isNull(stNo) || stNo.length() > ST_NO_MAX_LEN || NON_STR.equals(stNo);
        }).collect(Collectors.toList());
        System.out.println("编号校验不通过的数据有：" + stNoIsNotOk.toString());
        studentList.removeAll(stNoIsNotOk);
        System.out.println("编号校验通过的数据有：" + studentList.toString());
        return studentList;
    }
}
